Public Function ObtemProcessos() As ArrayList
Dim a As String
Dim b As New ArrayList
b.Clear()
Dim processos() = Process.GetProcesses
a = formata("Process Name", 40, "E", " ") + formata("Private Memory Size 64", 33, "E", " ")
For Each proc As Process In processos
a = 30 - Len(proc.ProcessName)
b.Add(formata(proc.ProcessName, 40, "E", " ") + formata(proc.PrivateMemorySize64.ToString("###,###,000"), 33, "D", " "))
Next
Return b
End Function
''' <summary>
''' devolve true se uma janela com o caption recebido por parametro esta aberta
''' </summary>
''' <param name="CaptionJanela"></param>
''' <returns></returns>
Public Function JanelaAberta(ByVal CaptionJanela As String) As Boolean
Dim myProcesses() As Process = Process.GetProcesses
For Each p As Process In myProcesses
'If Trim(p.MainWindowTitle) <> "" Then
'a = a + Trim(p.MainWindowTitle) + ";"
'End If
Debug.Print(p.MainWindowTitle)
If InStr(p.MainWindowTitle, CaptionJanela) <> 0 Then
Return True
End If
Next
Return False
End Function
Public Function ObtemProcessos2() As List(Of String)
Dim a As New List(Of String)
a.Clear()
For Each p As Process In Process.GetProcesses
'a.Add(p.ProcessName + vbTab + p.MainWindowTitle + vbTab + p.StartInfo.EnvironmentVariables("username"))
Select Case p.ProcessName 'todos são processos do sistema exceto case else que são processos do usuário
Case "svchost" : a.Add(p.ProcessName)
Case "gbpsv" : a.Add(p.ProcessName)
Case "snmp" : a.Add(p.ProcessName)
Case "Taskmgr" : a.Add(p.ProcessName)
Case "hkcmd" : a.Add(p.ProcessName)
Case "lsass" : a.Add(p.ProcessName)
Case "RuntimeBroker" : a.Add(p.ProcessName)
Case "sqlwriter" : a.Add(p.ProcessName)
Case "Idle" : a.Add(p.ProcessName)
Case "csrss" : a.Add(p.ProcessName)
Case "System" : a.Add(p.ProcessName)
Case "dllhost" : a.Add(p.ProcessName)
Case "wininit" : a.Add(p.ProcessName)
Case "IAStorIcon" : a.Add(p.ProcessName)
Case "spoolsv" : a.Add(p.ProcessName)
Case "smss" : a.Add(p.ProcessName)
Case "winlogon" : a.Add(p.ProcessName)
Case "services" : a.Add(p.ProcessName)
Case "PMBVolumeWatcher" : a.Add(p.ProcessName)
Case Else : a.Add(p.ProcessName + vbTab + p.MainWindowTitle) 'processos do usuário
End Select
'a.Add(p.ProcessName + vbTab + p.MainWindowTitle + vbTab + p.StartInfo.EnvironmentVariables("username"))
'eu só enxergo meus processos
Next
Return a
End Function